/********************************************************************************
*                 Copyright (C) 2011 - Las Venturas Playground                  *
*                      http://iv-mp.nl | http://lvp-iv.com                      *
*                                                                               *
*    This program is free software: you can redistribute it and/or modify       *
*    it under the terms of the GNU General Public License as published by       *
*    the Free Software Foundation, either version 3 of the License, or          *
*    (at your option) any later version.                                        *
*                                                                               *
*    This program is distributed in the hope that it will be useful,            *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of             *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
*    GNU General Public License for more details.                               *
*                                                                               *
*    You should have received a copy of the GNU General Public License          *
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
*                                                                               *
*********************************************************************************
*                                                                               *
*  Las Venturas Playground - Commands/adminCommands.nut                         *
*                                                                               *
*  This file will hold all admin commands.                                      *
*                                                                               *
********************************************************************************/

local cmdHandler = CommandHandler();

/**
 * The /w or /weapon command, crew can give themselves weapons with this command.
 * @author: Sander <sander@sa-mp.nl>
 *
 * @param playerid The playerid that used the command.
 * @param commandParams The weapon name or ID to spawn.
 * @param commandText The entire command as a string.
 */
function cmdWeapon (playerid, cmdWords, cmdStr)
{
    if (cmdWords.len() < 2) 
    {
        sendPlayerUsageMessage( playerid, "/w or /weapon [WeaponID or weaponname]" );
        return;
    }

    local matchNameWithWeapon = getWeaponIDFromName (cmdWords [1]);

    if (matchNameWithWeapon == -1)
    {
        sendPlayerErrorMessage (playerid, "No weapon found");
        return;
    }

    local weapon = matchNameWithWeapon.tointeger ();
    
    // Is the weapon valid?
    if (weapon < 0 || weapon == 6 || weapon == 8 || weapon > 18)
    {
        sendPlayerErrorMessage (playerid, "Invalid weapon id" );
        return;
    }
    
    givePlayerWeapon (playerid, weapon, 999);
    sendPlayerMessage (playerid, "You have been given a(n) " + weaponNames[weapon], COLOR_GREEN);
}

cmdHandler.registerCommand ("/w", Command (cmdWeapon), COMMAND_LEVEL_ADMINISTRATOR);
cmdHandler.registerCommand ("/weapon", Command (cmdWeapon), COMMAND_LEVEL_ADMINISTRATOR);

